package com.jianyun.jyzs.presenter;

import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
import com.jianyun.jyzs.bean.CrmCalendarCountBean;
import com.jianyun.jyzs.bean.CrmCalendarListBean;
import com.jianyun.jyzs.model.CrmCalendarModel;
import com.jianyun.jyzs.model.imdoel.ICrmCaledarModel;
import com.jianyun.jyzs.view.iview.ICrmCaledarView;

import java.util.List;

/**
 * Created by yangshijun on 2018/12/12.
 */

public class CrmCalendarPrenter extends MvpBasePresenter<ICrmCaledarView> {


    public void getCrmMonthCount(String enterpriseCode, String userId, String type, String year_month) {
        if (!isViewAttached()) return;
        getView().showLoaidng();
        CrmCalendarModel.getInstance().getCrmMonthCount(enterpriseCode, userId, type, year_month,
                new ICrmCaledarModel.OnGetMonthCountLisenter() {

                    @Override
                    public void onSuccess(List<CrmCalendarCountBean.DataList> data) {
                        getView().hideLoading();
                        getView().onCountSuccess(data);
                    }

                    @Override
                    public void onFailed() {
                        getView().hideLoading();
                    }

                    @Override
                    public void onException(String msg) {
                        getView().hideLoading();
                    }


                });
    }


    public void getCrmDateList(String enterpriseCode, String userId, String type, String workdate) {

        if (!isViewAttached()) return;
        getView().showLoaidng();
        CrmCalendarModel.getInstance().getCrmDateList(enterpriseCode, userId, type, workdate,
                new ICrmCaledarModel.OnGetCrmDateLisenter() {
                    @Override
                    public void onSuccess(List<CrmCalendarListBean.ListBean> data) {
                        getView().onCrmlistSuccess(data);
                        getView().hideLoading();
                    }

                    @Override
                    public void onFailed() {
                        getView().hideLoading();
                    }

                    @Override
                    public void onException(String msg) {
                        getView().hideLoading();
                    }
                });
    }
}
